<template>
<table>
    <tr>
        <td>项目名称</td>
        <td><input type="text" v-model="info.Iname"></td>
    </tr>
    <tr>
        <td>年收益</td>
        <td><input type="text" v-model="info.Ymoney">%</td>
    </tr>
    <tr>
        <td>月收益</td>
        <td><input type="text" v-model="info.Mmoney">%</td>
    </tr>
    <tr>
        <td>最低金额</td>
        <td><input type="text" v-model="info.Minmoney">元</td>
    </tr>
    <tr>
        <td>风险等级</td>
        <td><input type="text" v-model="info.Level">级</td>
    </tr>
    <tr>
        <td colspan="2">
            <input type="button" value="保存" @click="AddInvest">
        </td>
    </tr>
</table>
</template>
<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const router=useRouter()
const info=ref({
    Iname:'',
    Ymoney:0,
    Mmoney:0,
    Minmoney:0,
    Inum:0,
    Level:0,
})
const AddInvest=()=>{
    axios.post('https://localhost:44327/api/Lx/AddInvest',
        {
            Iname:info.value.Iname,
            Ymoney:info.value.Ymoney,
            Mmoney:info.value.Mmoney,
            Minmoney:info.value.Minmoney,
            Inum:info.value.Inum,
            Level:info.value.Level,
        }
    )
    .then(res=>{
        if(res.data==-1){
            alert('项目名称重复，添加失败')
            return
        }
        else if(res.data>0){
            alert('添加成功')
            router.push('/ShowInvest')
            return
        }else{
            alert("添加失败")
            return
        }
    })
}



</script>